<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<link th:href="@{/ajax/libs/summernote/summernote.css}" rel="stylesheet"/>
<link th:href="@{/ajax/libs/summernote/summernote-bs3.css}" rel="stylesheet"/>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form th:object="${cheyouhui}">
            <input id="cheyouhuiId" name="cheyouhuiId" th:field="*{cheyouhuiId}"  type="hidden">

			<div class="form-group">	
				<label class="col-sm-3 control-label">车友会名称：</label>
					<div class="col-sm-8">
				<input id="name" name="name" th:field="*{name}" class="form-control" readonly="readonly">
					</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">车友会会长：</label>
				<div class="col-sm-8">
				<input id="huiZhang" name="huiZhang" th:field="*{huiZhang}" class="form-control" readonly="readonly">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">车友会会长：</label>
				<div class="col-sm-8">
					<input id="huiZhang" name="huiZhang" th:field="*{huiZhang}" class="form-control" readonly="readonly">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">简介：</label>
				<div class="col-sm-8">
					<input id="jianJie" name="jianJie" th:field="*{jianJie}" class="form-control" type="hidden">
					<div id="editor" readonly="readonly" class="summernote"></div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">状态：</label>
				<div class="col-sm-8">
					<div class="onoffswitch">
						<input type="checkbox" th:checked="${cheyouhui.status == '0' ? true : false}" class="onoffswitch-checkbox" id="status" name="status">
						<label class="onoffswitch-label" for="status">
							<span class="onoffswitch-inner"></span>
							<span class="onoffswitch-switch"></span>
						</label>
					</div>
				</div>
			</div>

		</form>
    </div>
    <div th:include="include::footer"></div>
	<script th:src="@{/ajax/libs/summernote/summernote.min.js}"></script>
	<script th:src="@{/ajax/libs/summernote/summernote-zh-CN.js}"></script>
    <script type="text/javascript">
		var prefix = ctx + "system/cheyouhui";
		$("#form-cheyouhui-edit").validate({
			rules:{
				xxxx:{
					required:true,
				},
			}
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
				var sHTML = $('.summernote').summernote('code');
				$("#jianJie").val(sHTML);
	            $.operate.save(prefix + "/edit", $('#form-cheyouhui-edit').serialize());
	        }
	    }
		$(function() {
			$('.summernote').summernote({
				height : '220px',
				lang : 'zh-CN',
				callbacks: {
					onImageUpload: function (files) {
						sendFile(files[0], this);
					}
				}
			});
			var content = $("#jianJie").val();
			$('#editor').summernote('code', content);
		});

		// 上传文件
		function sendFile(file, obj) {
			var data = new FormData();
			data.append("file", file);
			$.ajax({
				type: "POST",
				url: ctx + "common/upload",
				data: data,
				cache: false,
				contentType: false,
				processData: false,
				dataType: 'json',
				success: function(result) {
					if (result.code == web_status.SUCCESS) {
						$(obj).summernote('editor.insertImage', result.url, result.fileName);
					} else {
						$.modal.alertError(result.msg);
					}
				},
				error: function(error) {
					$.modal.alertWarning("图片上传失败。");
				}
			});
		}
	</script>
</body>
</html>
